import Message from "@hi-ui/hiui/es/message";

export const transformTime = time => {
    if (!time) return null
    const newTime = new Date(time)
    const dd = t => (`0${t}`).slice(-2)

    const YYYY = newTime.getFullYear()
    const MM = dd(newTime.getMonth() + 1)
    const DD = dd(newTime.getDate())

    const hh = dd(newTime.getHours())
    const mm = dd(newTime.getMinutes())
    const ss = dd(newTime.getSeconds())

    return `${YYYY}-${MM}-${DD} ${hh}:${mm}:${ss}`
}

export const messageModal = (type, text) => {
    return Message.open({
        type: type,
        title: text
    })
}
